package com.dianjing.dianqun.api;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dianjing.dianqun.common.ResponseData;
import com.dianjing.dianqun.common.base.BaseRestController;
import com.dianjing.dianqun.model.Content;
import com.dianjing.dianqun.model.ContentCollection;
import com.dianjing.dianqun.model.ContentComment;
import com.dianjing.dianqun.model.ContentCommentExt;
import com.dianjing.dianqun.model.ContentCount;
import com.dianjing.dianqun.model.ContentExt;
import com.dianjing.dianqun.model.ContentLike;
import com.dianjing.dianqun.model.ContentTxt;
import com.dianjing.dianqun.model.CustomerService;
import com.dianjing.dianqun.model.Site;
import com.dianjing.dianqun.model.User;
import com.dianjing.dianqun.model.UserExt;
import com.dianjing.dianqun.model.dto.UserFlowDTO;
import com.dianjing.dianqun.service.ContentCollectionService;
import com.dianjing.dianqun.service.ContentCommentExtService;
import com.dianjing.dianqun.service.ContentCommentService;
import com.dianjing.dianqun.service.ContentCountService;
import com.dianjing.dianqun.service.ContentExtService;
import com.dianjing.dianqun.service.ContentLikeService;
import com.dianjing.dianqun.service.ContentService;
import com.dianjing.dianqun.service.ContentTxtService;
import com.dianjing.dianqun.service.SiteService;
import com.dianjing.dianqun.service.UserService;
import com.dianjing.dianqun.utils.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @date : 2017年10月13日
 * 
 * @author: baoyongtao
 * 
 * @see :
 * 
 */

@Api(value = "ContentApiContoller", description = "文章相关api")
@RestController
@RequestMapping("/api/content")
public class ContentApiContoller extends BaseRestController {
	@Autowired
	private CustomerService service;

	@Autowired
	private ContentService contentService;

	@Autowired
	private ContentCollectionService contentCollectionService;

	@Autowired
	private ContentTxtService contentTxtService;

	@Autowired
	private ContentCommentService commentService;

	@Autowired
	private ContentExtService contentExtService;

	@Autowired
	private ContentCountService contentCountService;

	@Autowired
	private ContentLikeService contentLikeService;

	@Autowired
	private UserService userService;
	
	@Autowired
	private ContentCommentExtService commentExtService;

	@Autowired
	private SiteService siteService;

	@ApiOperation(value = "根据id查找已审核文章", notes = "根据id查找文章")
	@GetMapping(value = "/detail/{id}")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "id", value = "文章id", dataType = "int", required = true, paramType = "path"),
			@ApiImplicitParam(name = "userId", value = "当前用户id，可以为空", dataType = "int", paramType = "query") })
	public ResponseData get(@PathVariable(name = "id", required = true) Integer id,HttpServletRequest request,
			@RequestParam(name = "userId", required = false) Integer userId) {
		Content content = contentService.selectByPrimaryKey(id);
		HashMap<String, Object> map = Maps.newHashMap();
		if (content == null) {
			return new ResponseData(ResponseData.STATUS_ERROR, "文章不存在", false);
		}
		ContentTxt contentTxt = contentTxtService.selectByContentId(content.getContentId());
		ContentExt contentExt = contentExtService.selectByPrimaryKey(content.getContentId());
		ContentCount contentCount = contentCountService.selectByPrimaryKey(content.getContentId());
		// 点赞数
		Integer likeTotal = contentLikeService.selectLikeByContentId(content.getContentId());
		contentCount.setLikeTotal(likeTotal);
		// 浏览量
		contentCount.setViews(contentCount.getViews() + 1);
		// 更新总浏览量
		contentCountService.updateByPrimaryKey(contentCount);
		content.setContentCount(contentCount);
		content.setContentTxt(contentTxt);
		content.setContentExt(contentExt);
		ArrayList<User> userList = new ArrayList<User>();
		// =====处理用户的粉丝和文章总数======
		User user = userService.selectByPrimaryKey(content.getUserId());
		UserExt ext = user.getExt();
		Integer fans = userService.selectFansByUserId(userId);
		if (null == ext) {
			ext = new UserExt();
		}
		//开始组装最近访客 自己不可算
		if(userId!=null && !userId.equals(content.getUserId())) {
			Site site = siteService.selectSitelByUserId(content.getUserId());
			if(site!=null) {
				Integer siteId = site.getSiteId();
				boolean isOk = saveSiteFlow(siteId,userId, request);
				if(!isOk) {
					//保存失败 可能要返回信息 目前 不做操作 主要发生在 发开期间
					LOG.error("Save site flow error !!");
				}
			}
		}
		if(userId!=null) {
			ext.setContentCount(contentService.selectCountByUserId(userId));
		}
		ext.setFans(fans);
		userList.add(user);
		// =========================
		// 评论
		PageHelper.startPage(0, 3);// 3条
		List<ContentComment> commentList = commentService.selectByContentId(content.getContentId(),userId);
		content.setCommentList(commentList);
		if (userId != null) {
			Boolean bothFolow = userService.isFolow(userId, user.getUserId());
			ContentLike contentLike = contentLikeService.selectLikeByUser(userId, content.getContentId());
			map.put("isLiked", null == contentLike ? false : true);
			map.put("isBothFolow", bothFolow);
		} else {
			map.put("isLiked", false);
			map.put("isBothFolow", false);
		}
		// 查询作者
		map.put("author", userList);
		// 开始组装推荐
		List<Content> recommendContent = contentService.selectContentRecommend(user.getUserId(), 10);
		if (CollectionUtils.isEmpty(recommendContent)) {
			// 如果推荐为空 则在查询20条猜你喜欢
			recommendContent = contentService.selectContentByLike(user.getUserId(), 2, 10);
		}
		// 开始组装猜你喜欢 最新更新的文章列表 根据用户id
		List<Content> selectAllContent = contentService.selectContentByLike(user.getUserId(), 1, 10);
		map.put("duessLike", selectAllContent);
		// 是否点赞
		ContentCollection collection = contentCollectionService.selectByPrimaryKey(userId, content.getContentId());
		map.put("isCollection", null == collection ? false : true);
		map.put("service", service);
		map.put("recommend", recommendContent);
		map.put("content", content);
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", map);
	}

	@ApiIgnore
	@ApiOperation(value = "查找已审核文章", notes = "分页查询已审核文章")
	@GetMapping(value = "/")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query") })
	public ResponseData list(@RequestParam(defaultValue = "20") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum) {
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectAllContent();
		PageInfo<Content> page = new PageInfo<>(list);
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "查找已审核文章", notes = "根据站点的id查找已审核文章")
	@GetMapping(value = "/site/{id}")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "id", required = true, value = "站点id", paramType = "path") })
	public ResponseData siteList(@RequestParam(defaultValue = "20") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @PathVariable(required = true) Integer id) {
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectContentBySiteId(id);
		PageInfo<Content> page = new PageInfo<>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "根据我关注的用户类型文章用户列表", notes = "根据我关注的用户类型文章用户列表")
	@GetMapping(value = "/query/user/type")
	@ApiImplicitParams({ 
			@ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "用户id", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "type", required = true, value = "用户类型（0：普通 1：律师 2：律所 3：律协）", paramType = "query") })
	public ResponseData selectUserListByType(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(required = true) Integer userId,
			@RequestParam(required = true) Integer type) {
		// 先查询最近访客的律师或者律协
		Site site = siteService.selectSitelByUserId(userId);
		List<UserFlowDTO> list = null;
		if (site != null) {
			PageHelper.startPage(pageNum, pageSize);
			list = userService.selectLatelyUserList(site.getSiteId(),userId,type);
			for (UserFlowDTO userFlowDTO : list) {
				PageHelper.startPage(1, 1);
				List<Content> contentList = contentService.selectContentByUserId(userFlowDTO.getUserId());
				if (CollectionUtils.isNotEmpty(contentList)) {
					Content content = contentList.get(0);
					ContentTxt contentTxt = content.getContentTxt();
					String txt = StringUtils.replaceHtml(contentTxt.getTxt());
					if (txt.length() > 201) {
						txt = txt.substring(0, 200);
					}
					contentTxt.setTxt(txt);
					content.setContentTxt(contentTxt);
					userFlowDTO.setContent(content);
				}
			}
		}
		PageInfo<UserFlowDTO> page = new PageInfo<>(list);
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "根据我关注的用户类型查询文章", notes = "根据用户我关注的类型查询文章")
	@GetMapping(value = "/{id}/{type}")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "id", required = true, value = "用户id", paramType = "path"),
			@ApiImplicitParam(dataType = "int", name = "type", required = true, value = "用户类型（0：普通 1：律师 2：律所 3：律协）", paramType = "path") })
	public ResponseData selectContentByType(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @PathVariable(required = true) Integer id,
			@PathVariable(required = true) Integer type) {
		// 先查询最近访客的律师或者律协
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectCountByType(id, type);
		PageInfo<Content> page = new PageInfo<Content>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "根据栏目id分页查找已审核文章", notes = "根据站点的id和栏目channel查找已审核文章")
	@GetMapping(value = "/channel/{channelId}")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "channelId", required = true, value = "栏目的id", paramType = "path") })
	public ResponseData siteChannelContent(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @PathVariable(required = true) Integer channelId) {
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.siteChannelContent(channelId);
		PageInfo<Content> page = new PageInfo<Content>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "查找已审核文章", notes = "根据用户的id和参数查找已审核文章")
	@GetMapping(value = "/user/{userId}")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "用户id", paramType = "path") })
	public ResponseData query(@RequestParam(defaultValue = "20") Integer pageSize,
			@PathVariable(required = true) Integer userId, @RequestParam(defaultValue = "1") Integer pageNum) {
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectContentByUserId(userId);
		PageInfo<Content> page = new PageInfo<Content>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiIgnore
	@ApiOperation(value = "根据类型查询关注的律师/律所文章", notes = "根据类型查询关注的律师/律所文章")
	@GetMapping(value = "/follow/{userId}/{type}")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "当前用户id", paramType = "path"),
			@ApiImplicitParam(dataType = "int", name = "type", required = true, value = "用户类型（1:律师 2 ：律所）", paramType = "path"),
			@ApiImplicitParam(dataType = "string", name = "lastTime", required = true, value = "上次查看时间(yyyy-MM-dd hh:mm:ss)", paramType = "query") })
	public ResponseData query(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @PathVariable(required = true) Integer type,
			@PathVariable(required = true) Integer userId, @RequestParam(required = true) String lastTime) {
		if (!(type.equals(1) || type.equals(2))) {
			return new ResponseData(ResponseData.STATUS_ERROR, "用户类型错误", type);
		}
		try {
			DateUtils.parseDate(lastTime, "yyyy-MM-dd hh:mm:ss");
		} catch (ParseException e) {
			return new ResponseData(ResponseData.STATUS_ERROR, "日期类型错误", lastTime);
		}
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectContentByFollow(userId, type, lastTime);
		PageInfo<Content> page = new PageInfo<>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	@ApiOperation(value = "根据关键字搜索已审核文章", notes = "根据关键字搜索已审核文章")
	@GetMapping(value = "/search")
	@ApiImplicitParams({ @ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "string", name = "keyword", required = true, value = "搜索的关键字", paramType = "query") })
	public ResponseData search(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(required = true) String keyword) {
		PageHelper.startPage(pageNum, pageSize);
		List<Content> list = contentService.selectContentByKeyowrd(keyword);
		PageInfo<Content> page = new PageInfo<>(replaceContentTxt(list));
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}

	/**
	 * 替換文章内容html并截取
	 * 
	 * @param list
	 * @return
	 */
	private List<Content> replaceContentTxt(List<Content> list) {
		for (Content content : list) {
			ContentTxt contentTxt = content.getContentTxt();
			String txt = StringUtils.replaceHtml(contentTxt.getTxt());
			if (txt.length() > 101) {
				contentTxt.setTxt(txt.substring(0, 100));
			}else {
				contentTxt.setTxt(txt);
			}
			content.setContentTxt(contentTxt);
		}
		return list;
	}
	@ApiOperation(value = "收藏/取消点拍文章", notes = "用户收藏点拍文章")
	@GetMapping(value = "/collection/{userId}/{contentId}")
	@ApiImplicitParams({
			@ApiImplicitParam(dataType = "int", name = "status", required = true, value = "是否收藏(0:是 1：取消)", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "用戶Id", paramType = "path"),
			@ApiImplicitParam(dataType = "int", name = "contentId", required = true, value = "点拍文章Id", paramType = "path")
	})
	public ResponseData collection(@PathVariable(required=true) Integer userId, @RequestParam(required=true) Integer status, 
				@PathVariable(required=true) Integer contentId) {
		Content content = contentService.selectByPrimaryKey(contentId);
		User user = userService.selectByPrimaryKey(userId);
		if(null==user||content==null) {
			return new ResponseData(ResponseData.STATUS_ERROR, "参数错误", false);
		}
		if(content.getUserId().equals(userId)) {
			//自己不能收藏自己的文章
			return new ResponseData(ResponseData.STATUS_ERROR, "不能自己收藏自己的文章", false);
		}
		ContentCollection contentCollection = contentCollectionService.selectByPrimaryKey(userId, contentId);
		Boolean isCollection=null;
		if(status.equals(0)) {
			//收藏点拍
			//查询是否收藏
			if(contentCollection==null) {
				//开始收藏
				ContentCollection collection = new ContentCollection();
				collection.setContentId(contentId);
				collection.setUserId(userId);
				contentCollectionService.insertSelective(collection);
			}
			isCollection=true;
		}else if(status.equals(1)){//取消收藏
			if(contentCollection!=null) {
				contentCollectionService.cancelCollection(userId,contentId);
			}
			isCollection=false;
		}
		return new ResponseData(ResponseData.STATUS_OK, (status.equals(0)?"":"取消")+"收藏完成",isCollection);
		
	}
	
	
	@ApiOperation(value = "点赞/取消点拍文章", notes = "用户点赞/取消点拍文章")
	@GetMapping(value = "/likeContent/{userId}/{contentId}")
	@ApiImplicitParams({
			@ApiImplicitParam(dataType = "int", name = "status", required = true, value = "是/取消 点赞(0:是 1：取消)", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "用戶Id", paramType = "path"),
			@ApiImplicitParam(dataType = "int", name = "contentId", required = true, value = "点拍文章Id", paramType = "path")
	})
	public ResponseData likeContent(@PathVariable(required=true) Integer userId, @RequestParam(required=true) Integer status, 
			@PathVariable(required=true) Integer contentId) {
		Content content = contentService.selectByPrimaryKey(contentId);
		User user = userService.selectByPrimaryKey(userId);
		if(null==user||content==null) {
			return new ResponseData(ResponseData.STATUS_ERROR, "参数错误", false);
		}
		Boolean isCollection=null;
		//查询赞
		ContentLike contentLike = contentLikeService.selectLikeByUser(userId, contentId);
		if(status.equals(0)) {
			//开始点赞
			if(contentLike==null) {
				ContentLike like=new ContentLike();
				like.setContentId(contentId);
				like.setLikeDate(new Date());
				like.setLikeUserId(userId);
				contentLikeService.insertSelective(like);
			}
			  isCollection=true;
		}else if(status.equals(1)) {
			if(contentLike!=null) {
				contentLikeService.cancelLikeByContentId(userId,contentId);
			}
			isCollection=false;
		}
		
		return new ResponseData(ResponseData.STATUS_OK, (status.equals(0)?"":"取消")+"点赞完成",isCollection);
	}
	
	
	@ApiOperation(value = "根据文章id分页查询评论列表", notes = "根据文章id分页查询评论列表")
	@GetMapping(value = "/commentlist/{contentId}")
	@ApiImplicitParams({ 
			@ApiImplicitParam(dataType = "int", name = "pageSize", value = "每页多少记录", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "pageNum", value = "当前页", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "userId", value = "当前用户id", paramType = "query"),
			@ApiImplicitParam(dataType = "int", name = "contentId", required = true, value = "文章id", paramType = "path") 
	})
	public ResponseData commentList(@RequestParam(defaultValue = "10") Integer pageSize,
			@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "1") Integer userId,
			@PathVariable(required = true) Integer contentId) {
		PageHelper.startPage(pageNum, pageSize);
		List<ContentComment> list = commentService.selectByContentId(contentId,userId);
		PageInfo<ContentComment> page = new PageInfo<ContentComment>(list);
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", page);
	}
	
	
	
	@ApiOperation(value = "保存文章评论", notes = "保存文章评论")
	@PostMapping(value = "/comment/save")
	@ApiImplicitParams({
		@ApiImplicitParam(dataType = "int", name = "contentId", required = true, value = "点拍文章id", paramType = "query"),
		@ApiImplicitParam(dataType = "int", name = "fromUserId", required = true, value = "评论人id", paramType = "query"),
		@ApiImplicitParam(dataType = "int", name = "comment", required = true, value = "评论内容", paramType = "query") 
	})
	public ResponseData saveComment(@RequestParam(required = true) Integer contentId, HttpServletRequest request,
			@RequestParam(required = true) Integer fromUserId,
			@RequestParam(required = true) String comment) {
		
		User fromUser = userService.selectByPrimaryKey(fromUserId);
		if(null==fromUser) {
			return new ResponseData(ResponseData.STATUS_ERROR, "评论失败，用户不存在", contentId);
		}
		Content content = contentService.selectByPrimaryKey(contentId);
		if(null==content) {
			return new ResponseData(ResponseData.STATUS_ERROR, "查询失败，文章不存在", contentId);
		}
		User user = userService.selectByPrimaryKey(fromUserId);
		ContentComment	contentComment = commentService.save(content,fromUserId,comment);
		contentComment.setCommentUser(user);
		return new ResponseData(ResponseData.STATUS_OK, "查询完成", contentComment);
	}

	
	
	@ApiOperation(value = "回复文章评论，只限作者回复，多次回复将被覆盖", notes = "回复文章评论，只限作者回复，多次回复将被覆盖")
	@PostMapping(value = "/comment/reply")
	@ApiImplicitParams({
		@ApiImplicitParam(dataType = "int", name = "commentId", required = true, value = "评论id", paramType = "query"),
		@ApiImplicitParam(dataType = "int", name = "userId", required = true, value = "当前用户id", paramType = "query"),
		@ApiImplicitParam(dataType = "int", name = "reply", required = true, value = "回复内容", paramType = "query") 
	})
	public ResponseData replyComment(@RequestParam(required = true) Integer commentId, HttpServletRequest request,
			@RequestParam(required = true) String reply,@RequestParam("userId") Integer userId) {
		ContentComment contentComment= commentService.selectByUserIdChecked(commentId,userId);
		if(null==contentComment) {
			return new ResponseData(ResponseData.STATUS_ERROR, "查询失败，评论不存在", commentId);
		}
		ContentCommentExt commentExt = commentExtService.selectByPrimaryKey(commentId);
		commentExt.setReply(reply);
		commentExtService.updateByPrimaryKey(commentExt);
		User user = userService.selectByPrimaryKey(contentComment.getCommentUserId());
		contentComment.setCommentUser(user);
		contentComment.setCommentExt(commentExt);
		return new ResponseData(ResponseData.STATUS_OK, "操作完成", contentComment);
	}
}
